#include"msg.hpp"

int main()
{
    cout<<"hello im msg_server.cc"<<endl;
    int key=getkey();
  int msgid=  creatmsg(key);
    sleep(1);
    cout<<"server create msgqueue success\n"<<endl;
    //发送消息
    char buf[1024];
    while(true)
    {
 buf[0]=0;
 receivemsg(msgid,CLIENT_TYPE,buf);
 printf("client# %s\n",buf);
 printf("please enter# ");
 fflush(stdout);
 ssize_t s=read(0,buf,sizeof(buf));
 if(s>0)
 {
    buf[s-1]=0;
    sendmsg(msgid,SERVER_TYPE,buf);
    printf("send done,wait recieve:...\n");
 }
    }
    sleep(1);
        deletemsg(msgid);
     cout<<"server delete msgqueue success\n"<<endl;
    return 0;
}